<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>$课堂练习$</title>
</head>
<body>
<input type="button" value="变色" id="btn">
<ul id="uu">
    <li>老司机</li>
    <li>老司机</li>
    <li>老司机</li>
    <li>老司机</li>
    <li>老司机</li>
    <li>老司机</li>
    <li>老司机</li>
    <li>老司机</li>
</ul>
<script src="common.js"></script>
<script>
    my$("btn").onclick = function () {
        var nodes = my$("uu").childNodes;
        var count = 0;
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].nodeType == 1 && nodes[i].nodeName == "LI") {
                nodes[i].style.backgroundColor = count % 2 == 0 ? "red" : "yellow";
                count++;
            }
            ;
        }
        ;
    };
</script>
</body>
</html>